package com.weather.data.controller;

import com.weather.data.entity.DO.User;
import com.weather.data.entity.VO.UserPageVO;
import com.weather.data.result.Result;
import com.weather.data.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2024-12-23
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户管理")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/getUserByPage")
    @ApiOperation(value = "获取用户分页")
    @ApiImplicitParam(name = "userPageVO", value = "用户分页条件", dataTypeClass = UserPageVO.class)
    public Result getUserByPage(UserPageVO userPageVO) {
        return Result.success().addBody("data", userService.getUserByPage(userPageVO));
    }

    @PostMapping("/addUser")
    @ApiOperation(value = "添加用户")
    @ApiImplicitParam(name = "user", value = "用户分页条件", dataTypeClass = User.class)
    public Result addUser(@RequestBody User user) {
        return Result.success().addBody("data", userService.addUser(user));
    }


}
